package com.zhl.extends_constructor12;

import com.zhl.extends8.Teacher;

public class Test2 {
    public static void main(String[] args) {
        //目标：搞清楚子类构造器为什么要调用父类的构造器，有啥应用场景
        Teacher1 t1 = new Teacher1("张三", 25, "语文");
        System.out.println(t1.getSkill());
        System.out.println(t1.getAge());
        System.out.println(t1.getName());

    }
}



class Teacher1 extends People{
    private String skill;

    public Teacher1(String name, int age, String skill) {
        super(name, age);//调用父类的构造器
        this.skill = skill;
    }

    public String getSkill() {
        return skill;
    }

    public void setSkill(String skill) {
        this.skill = skill;
    }
}

class People{
    private String name;
    private int age;
    public People(){
        //默认构造器
    }
    public People(String name, int age){
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

